-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed false positives for function stubs #2927
Conversation
1 similar comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff! Left two minor comments to check before merging.
pylint/checkers/base.py
Outdated
defined_self = parent_frame[node.name] | ||
# Ignore function stubs created for type information | ||
defined_self = next( | ||
local |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to throw a sentinel in there with next((....), None)
so we won't crash if we can't find a proper local.
pylint/checkers/variables.py
Outdated
return | ||
|
||
# Don't check function stubs created only for type information | ||
if utils.decorated_with(node, "typing.overload"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use is_overload_stub
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep! 😅
Description
This change fixes
unused-argument
andfunction-redefined
getting raised for functions decorated withtyping.overload
.unused-argument
ignores these functions altogether.function-redefined
does not treat them as actual definitions, both when checking the node itself and when looking for duplicate definition nodes.Type of Changes
Related Issue
Close #1581